//package com.example.test.bean;
//
//import com.dingtalk.api.DefaultDingTalkClient;
//import com.dingtalk.api.DingTalkClient;
//import com.dingtalk.api.request.OapiRobotSendRequest;
//import com.dingtalk.api.response.OapiRobotSendResponse;
//import com.taobao.api.ApiException;
//import org.apache.tomcat.util.codec.binary.Base64;
//
//import java.io.UnsupportedEncodingException;
//import java.security.InvalidKeyException;
//import java.security.NoSuchAlgorithmException;
//import java.util.Arrays;
//
//import javax.crypto.Mac;
//import javax.crypto.spec.SecretKeySpec;
//import java.net.URLEncoder;
//
//
//public class 自定义机器人 {
//
//    public static void main(String[] args) throws ApiException, NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
//        Long timestamp = System.currentTimeMillis();
//        String secret = "SECe8fa59751699db3422219ee15eb1e455c3229d7862ed22d6932076546c71a033";
//
//        String stringToSign = timestamp + "\n" + secret;
//        Mac mac = Mac.getInstance("HmacSHA256");
//        mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
//        byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
//        String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8");
//
//        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=d0f36c547751bb522436048e8ed60c3899727643aeb52d3acf6ef7c71db11820&sign="+sign+"&timestamp="+timestamp);
//        OapiRobotSendRequest request = new OapiRobotSendRequest();
//        request.setMsgtype("text");
//        OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
//        text.setContent("互相伤害");
//        request.setText(text);
//        OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
//        at.setAtMobiles(Arrays.asList("18953184087"));
//        at.setIsAtAll(true);
//        request.setAt(at);
//        OapiRobotSendResponse response = client.execute(request);
//    }
//}
//
//
